import { createStore } from "vuex";

import config from "./config";
import user from "./user";

import { plugin as userPlugin } from "./user/plugin";
// import example from './module-example'

/*
 * If not building with SSR mode, you can
 * directly export the Store instantiation;
 *
 * The function below can be async too; either use
 * async/await or return a Promise which resolves
 * with the Store instance.
 */

export default function (/* { ssrContext } */) {
  const Store = createStore({
    state() {
      return {
        count: 111, // 在视图中通过$store.state.count来获取
      };
    },
    modules: {
      // example
      config,
      user,
    },
    plugins: [userPlugin],
    // enable strict mode (adds overhead!)
    // for dev mode and --debug builds only
    strict: process.env.DEBUGGING,
  });

  return Store;
}
